package ynu.sxp.demoapp.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import ynu.sxp.demoapp.entity.Business;
import ynu.sxp.demoapp.service.BusinessService;
import ynu.sxp.demoapp.common.Result;

import java.util.List;
import java.util.UUID;

@RestController
@RequestMapping("/BusinessController")
public class BusinessController {

    @Autowired
    private BusinessService businessService;

    // 根据订单类型ID获取商家列表
    @GetMapping("/listBusinessByOrderTypeId")
    public Result<List<Business>> listBusinessByOrderTypeId(@RequestParam Integer orderTypeId) {
        List<Business> businesses = businessService.getBusinessesByOrderTypeId(orderTypeId);
        return Result.success(businesses);
    }

    // 根据商家ID获取商家信息
    @GetMapping("/getBusinessById")
    public Result<Business> getBusinessById(@RequestParam UUID businessId) {
        Business business = businessService.getBusinessById(businessId);
        return Result.success(business);
    }

    // 获取所有商家信息
    @GetMapping("/listAllBusinesses")
    public Result<List<Business>> listAllBusinesses() {
        List<Business> businesses = businessService.getAllBusinesses();
        return Result.success(businesses);
    }
}